package com.netty.im.client;

import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

import java.util.concurrent.TimeUnit;

/**
 * Created by Administrator on 2018/9/9/009.
 */
public class ImClientHandler extends SimpleChannelInboundHandler<String> {

    Bootstrap bootStrap;

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
        System.out.println(msg);
    }

    @Override
    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
        ctx.channel().eventLoop().schedule(new Runnable() {
            @Override
            public void run() {
                bootStrap.connect("localhost", 8899);
            }
        }, 2, TimeUnit.SECONDS);
    }
}
